//--------------------------------------------------------------------------------------
// Rasterizer states
//--------------------------------------------------------------------------------------

RasterizerState CullFront {
    CullMode = Back;
};

RasterizerState CullBack {
    CullMode = Front;
};

RasterizerState CullNone {
    CullMode = None;
};

//--------------------------------------------------------------------------------------
// Blend states
//--------------------------------------------------------------------------------------

BlendState AlphaBlending {
    AlphaToCoverageEnable = FALSE;
    SrcBlend = SRC_ALPHA;
    DestBlend = INV_SRC_ALPHA;
    BlendOp = ADD;
    SrcBlendAlpha = ZERO;
    DestBlendAlpha = ZERO;
    BlendOpAlpha = ADD;
    
    BlendEnable[0] = TRUE;
    BlendEnable[1] = TRUE;
    BlendEnable[2] = TRUE;
    BlendEnable[3] = TRUE;
    BlendEnable[4] = TRUE;
    BlendEnable[5] = TRUE;
    BlendEnable[6] = TRUE;
    BlendEnable[7] = TRUE;
    
    RenderTargetWriteMask[0] = 0x0F;
    RenderTargetWriteMask[1] = 0x0F;
    RenderTargetWriteMask[2] = 0x0F;
    RenderTargetWriteMask[3] = 0x0F;
    RenderTargetWriteMask[4] = 0x0F;
    RenderTargetWriteMask[5] = 0x0F;
    RenderTargetWriteMask[6] = 0x0F;
    RenderTargetWriteMask[7] = 0x0F;   
};

BlendState AdditiveBlending
{
    AlphaToCoverageEnable = FALSE;    
    SrcBlend = ONE;
    DestBlend = ONE;
    BlendOp = ADD;
    SrcBlendAlpha = ONE;
    DestBlendAlpha = ONE;
    BlendOpAlpha = ADD;
    
    BlendEnable[0] = TRUE;
    BlendEnable[1] = TRUE;
    BlendEnable[2] = TRUE;
    BlendEnable[3] = TRUE;
    BlendEnable[4] = TRUE;
    BlendEnable[5] = TRUE;
    BlendEnable[6] = TRUE;
    BlendEnable[7] = TRUE;
    
    RenderTargetWriteMask[0] = 0x0F;
    RenderTargetWriteMask[1] = 0x0F;
    RenderTargetWriteMask[2] = 0x0F;
    RenderTargetWriteMask[3] = 0x0F;
    RenderTargetWriteMask[4] = 0x0F;
    RenderTargetWriteMask[5] = 0x0F;
    RenderTargetWriteMask[6] = 0x0F;
    RenderTargetWriteMask[7] = 0x0F;    
}; 

BlendState BlendOver {
    AlphaToCoverageEnable = FALSE;
    SrcBlend = SRC_ALPHA;
    DestBlend = INV_SRC_ALPHA;
    BlendOp = ADD;
    SrcBlendAlpha = ONE;
    DestBlendAlpha = ONE;
    BlendOpAlpha = ADD;

    BlendEnable[0]			 = TRUE;
    BlendEnable[1]			 = TRUE;
    BlendEnable[2]			 = TRUE;
    BlendEnable[3]			 = TRUE;
    BlendEnable[4]			 = TRUE;
    BlendEnable[5]			 = TRUE;
    BlendEnable[6]			 = TRUE;
    BlendEnable[7]			 = TRUE;

    RenderTargetWriteMask[0] = 0x0F;
	RenderTargetWriteMask[1] = 0x0F;
    RenderTargetWriteMask[2] = 0x0F;
    RenderTargetWriteMask[3] = 0x0F;
    RenderTargetWriteMask[4] = 0x0F;
    RenderTargetWriteMask[5] = 0x0F;
    RenderTargetWriteMask[6] = 0x0F;
    RenderTargetWriteMask[7] = 0x0F;
};

BlendState NoBlending {
    AlphaToCoverageEnable = FALSE;
    BlendEnable[0] = FALSE;
    BlendEnable[1] = FALSE;
    BlendEnable[2] = FALSE;
    BlendEnable[3] = FALSE;
    BlendEnable[4] = FALSE;
    BlendEnable[5] = FALSE;
    BlendEnable[6] = FALSE;
    BlendEnable[7] = FALSE;
};

//--------------------------------------------------------------------------------------
// DepthStencil states
//--------------------------------------------------------------------------------------

DepthStencilState EnableDepth {
    DepthEnable = TRUE;
    DepthWriteMask = ALL;
    DepthFunc = LESS_EQUAL;

	//Stencil
    StencilEnable = false;
    StencilReadMask = 0xFF;
    StencilWriteMask = 0x00;
};

DepthStencilState DisableDepth {
    DepthEnable = false;
    DepthWriteMask = ZERO;
    DepthFunc = Less;

    //Stencil
    StencilEnable = false;
    StencilReadMask = 0xFF;
    StencilWriteMask = 0x00;
};

DepthStencilState NoWriteDepth {
    DepthEnable = TRUE;
    DepthWriteMask = ZERO;
    DepthFunc = LESS_EQUAL;

    //Stencil
    StencilEnable = false;
    StencilReadMask = 0xFF;
    StencilWriteMask = 0x00;
};

float2 dim(Texture2D textureObj)
{
	uint width;
	uint height;
	textureObj.GetDimensions(width, height);
	return float2(width, height);
}

float4 GetFinalColor(float4 fvBaseColor, float4 fvTotalDiffuse, float4 fvTotalSpecular, float3 Color, float tt, float4 LghtColor , float4 OcclColor, float4 Cube, float4 Cube2)
{
//New
	
return 
	//Ambient
	pow(OcclColor+0.1,2)*fvBaseColor*(Cube2*5+1.0)*0.16
	//Self
	+ LghtColor * 4
	//Reflect
	+ Cube*pow(OcclColor+0.1, 2)*0.6
	//Difuse
    + ((OcclColor*0.5 + 0.5)*fvTotalDiffuse*1.0 + fvTotalSpecular*0.5)*tt*float4(Color,1) ;

//Old
//return OcclColor*OcclColor*fvBaseColor*Cube2*0.5+OcclColor*OcclColor*fvBaseColor*0.2 +  (OcclColor*fvTotalDiffuse *tt + fvTotalSpecular *tt *3 )*float4(Color,1) + Cube*0.5*OcclColor + LghtColor * 4;

}